<template>
	<view>
		<view :style="'background-image:url('+get_img+bgFunc()+');'" class="image">
			<!-- <image class="image" :src='get_img + sys.egg_bg'></image> -->
		</view>
		<view>
			<image class="image1" :src='get_img + sys.egg_bg'></image>
		</view>
		<view class="active">
			<u-tabs :list="list1" @click="click" :scrollable='scrollable' :activeStyle='activeStyle'
				:inactiveStyle='inactiveStyle' ></u-tabs>
			<!-- <u-tabs :list="list1" @click="click" scrollable="false" lineColor="#fff"></u-tabs> -->
		</view>



		<view class="convert" v-for="(item,index) in list" :key="index" v-if="item.state==state">
			<view>
				<image :src="get_img+sys.egg_icon"
					class="img" ></image>
			</view>
			<view class="active_1">
				<p class="content_p">鸡蛋X{{item.num}}</p>
				<p  class="updated_p">{{item.created_at}}</p>
				<view class="receive">
					
					<view class="hx">
						<u-tag v-if="item.state==0" text="核销码" type="error" size="mini" shape="circle"
							@click="hx(item)"></u-tag>
					</view>
				</view>
			</view>
			<view class="_a">
				<u-line color="#fff" hairline="false"></u-line>
			</view>
		</view>


		<u-popup :show="show" mode="center" v-if="qrcode" @close="close" @open="open" closeable="true">
			<view  class="jphx">
				<text>奖品核销</text>
			</view>
			<image :src="get_img+qrcode" class="jphx_img"></image>
		</u-popup>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				list1: [{
					name: '待领取',
				}, {
					name: '已领取',
				}],
				get_img: this.$get_img,
				state: 0,
				is_reach: false,
				qrcode: "",
				show: false,
				page: 1,
				num: 10,
				activeStyle: {
					color: '#000'
				},
				inactiveStyle: {
					color: '#000'
				},
				sys: {},
				list: []
			}
		},
		onLoad() {
			this.sys = uni.getStorageSync("sys")
			this.get_log()
		},
		onReachBottom() {
			if (!this.is_reach) {
				this.page++
				this.get_log()
			}

		},
		methods: {
			bgFunc() {
				return this.sys.egg_get_bg != '' ? this.sys.egg_get_bg : this.sys.sys_background
			},

			open() {
				console.log('open');
			},
			get_log() {
				let that = this
				this.$model.get("user/common/get_egg_logs?page=" + this.page + "&num=" + this.num + "&state=" + this.state)
					.then(res => {
						if (res.code == 200) {
							if (res.data.data.length == 0) {
								uni.showToast({
									title: "没有更多了"
								})
								that.is_reach = true
							}

							res.data.data.forEach(function(value) {
								that.list.push(value)
							})
							console.log("list:",this.list)
						}
					})
			},
			click(item) {
				console.log("item:",item)
				this.state = item.index
				this.page = 1
				this.list = []
				this.get_log()
			},
			hx(item) {
				this.qrcode = item.qrcode;
				this.show = true
				console.log(item)
			},
		
			close() {
				this.show = false

			}
		}

	}
</script>

<style>
	.image {
		background-repeat: no-repeat;
		background-size: 100% 100%;
		background-attachment: fixed;
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100vh;
		z-index: -1;
	}
	
	._a {
		width: 750rpx;
		margin-top: -20rpx;
	
	}
	
	.jphx {
		text-align: center;
		color: orangered;
	}
	
	.image1 {
		width: 100vw;
		height: 150px;
	}
	
	.active {
		color: #000;
		background-color: rgba(255, 255, 255, .5);
		margin: -10rpx 0 0 0;
	}
	
	.jphx_img {
		width: 400rpx;
		height: 400rpx;
	}
	
	.active_1 {
		/* background-color: rgba(255, 255, 255, .5); */
		margin: -198rpx 200rpx 0 260rpx;
		height: 150rpx;
		width: 480rpx;
	}
	
	.convert {
		width: 100vw;
		height: 200rpx;
		color: #000;
		/* background-color: rgba(0, 0, 0, .5); */
	
	}
	
	.hx {
		/* margin: 50rpx 0 50rpx; */
		margin-top: 60rpx;
		margin-right: 50rpx;
	
	}
	
	.content_p {
		margin: 50rpx 20rpx 20rpx 20rpx;
		font-size: 35rpx;
	
	}
	
	.updated_p {
		margin: 0rpx 20rpx 50rpx 20rpx;
		font-size: 30rpx;
	
	}
	
	.img {
		width: 150rpx;
		height: 150rpx;
		margin: 20rpx 40rpx 20rpx 60rpx;
	}
	
	.receive {
		float: right;
		margin-top: -188rpx;
	}
</style>
